import strutils

proc isValid*(isbn: string): bool = 
  var
    sum = 0
    i = 10

  for c in isbn:
    if c == '-':
      discard c
    elif i != 0 and c in Digits:
      sum.inc(i * (c.ord - '0'.ord))
      dec i
    elif i == 1 and c in {'X','x'}:
      sum.inc(10)
      dec i
    else:
      return false

  i == 0 and sum mod 11 == 0